import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { TilePanel } from "../equipment/TilePanel";
import { GroupRequestRenderer } from "./GroupRequestRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GButton } from "../../../../com/mui/controls/GButton";
import { _isCross } from "../../../../this/_isCross";
import { _isInvite } from "../../../../this/_isInvite";
import { _dataArray } from "../../../../this/_dataArray";
type int = number;
//class GroupRequestWindow
    
    export  class GroupRequestWindow extends BaseWindow
    {
        constructor(arg1: Boolean)
        {
            super();
            this._isCross = arg1;
            this.setSize(325, 155);
            this.titleHeight = 28;
            this.title = Language.getString(62043);
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._bg = ObjCreate.createBg(17, 39, 290, 80, this);
            this._requestList = new TilePanel();
            this._requestList.horizontalGap = 3;
            this._requestList.verticalGap = 3;
            this._requestList.columnWidth = 260;
            this._requestList.rowHeight = 60;
            this._requestList.setSize(260, 60);
            this._requestList.move(40, 50);
            this._requestList.setStyle("cellRenderer", GroupRequestRenderer);
            this.addChild(this._requestList);
            this._dp = new DataProvider();
            this._ignoreBtn = ObjCreate.createGButton(Language.getString(62044), 220, 120, 70, 24, this);
            this._ignoreBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onIgnoreBtnClickHandler);
            return;
        }

        public updateDataProvider(arg1: Array<any>, arg2: Boolean): void
        {
            var loc1=null;
            this._isInvite = arg2;
            this._dataArray = [];
            this.resetWindow(arg1.length);
            this._dp.removeAll();
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                loc1 = arg1[loc2] as Object;
                this._dataArray.push(loc1);
                this._dp.addItem({"data": loc1, "isInvite": arg2, "isCross": _isCross});
                ++loc2;
            }
            this._requestList.dataProvider = this._dp;
            return;
        }

        /* internal  */resetWindow(arg1: int): void
        {
            if (arg1 <= 4) 
            {
                this.height = 155 + (arg1 - 1) * 60;
                this._bg.height = 80 + (arg1 - 1) * 60;
                this._requestList.setSize(250, 60 + (arg1 - 1) * 60);
                this._ignoreBtn.y = 120 + (arg1 - 1) * 60;
            }
            else 
            {
                this.height = 155 + (4 - 1) * 60;
                this._bg.height = 80 + (4 - 1) * 60;
                this._requestList.setSize(250, 60 + (4 - 1) * 60);
                this._ignoreBtn.y = 120 + (4 - 1) * 60;
            }
            if (arg1 != 1) 
            {
                this._ignoreBtn.label = Language.getString(62045);
            }
            else 
            {
                this._ignoreBtn.label = Language.getString(62044);
            }
            return;
        }

        /* internal  */onIgnoreBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._isCross) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CrossGroup_RefuseAll, {"isInvite": _isInvite, "dataArray": _dataArray}));
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Group_RefuseAll, {"isInvite": _isInvite, "dataArray": _dataArray}));
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this.updateDataProvider([], true);
            return;
        }

        public static /* const */Type_invite: int=0;

        public static /* const */Type_apply: int=1;

        /* internal */ /* var */_isCross: Boolean;

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_dp: DataProvider;

        /* internal */ /* var */_requestList: TilePanel;

        /* internal */ /* var */_ignoreBtn: GButton;

        /* internal */ /* var */_isInvite: Boolean;

        /* internal */ /* var */_dataArray: Array<any>;
    }
